<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/kendocommon.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>游戏课程（托班）</title>
    <meta charset="utf-8">
    <style>
    	table{font-size:12px}
    </style>
    <script>
        $(document).ready(function() {
        	
        	$("#toolbar").kendoToolBar({
	            resizable: false,
	            items: [
	            	{ type: "separator" },
	                { template: "<label>时间:</label><input name='date_from' id='date_from'>" },
	                { template: "<label>-</label><input name='date_to' id='date_to'>" },
					{ type: "separator" },
	                //{ template: selectTemp},
	                //{ type: "separator" },
	                { type: "button", text: "查询",click: queryCustomerList }
	            ]
	        });
	        
            dataSource = new kendo.data.DataSource({
                transport: {
                    read:  {
                        url: "${path}/assist/queryCourseInfoList?course_type_code=2",
                        dataType: "json",
                        data: function() {
					        return {
					         	date_from:$('#date_from').val(),
					         	date_to:$('#date_to').val()
					        };
					    }
                    }
                },
                //group: [{field: "deptName"}],
                serverPaging: true,
                serverFiltering: true,
                pageSize: 15,
                schema: {
                	data:"data",
               		total:"total"
                }
            });
            
            $("#grid").kendoGrid({
                dataSource: dataSource,
                pageable: {
					refresh: true,
					pageSizes: true,
					buttonCount: 5,
					page: 1,
					pageSize: 10,
					pageSizes: [10, 20, 30],
					messages: {
						display: "显示 {0}-{1} 共 {2} 项",
						empty: "没有数据",
						itemsPerPage: "每面显示数量",
						first: "第一页",
						last: "最后一页",
						next: "下一页",
						previous: "上一页"
					}
				},
                selectable: "multiple row",
                allowCopy: true,
                groupable: {
                    messages: {
                      empty: "将列拖拽到此处进行分类查看"
                    }
                },
                editable: "popup",
                columns: [
                	//{ field:"id", template: "<input type='checkbox' id='#:id#' />",width: "120px",headerTemplate: '<input type="checkbox" id="check-all" />'},
                    { field: "course_start_time", title:"上课时间",  width: "120px"},//format: "{0:c}",locked: true,
                    { field:"course_index", title: "班次",width: "150px"},
                    { field:"typename", title: "课程类型",width: "150px"},
                    { field:"zjname", title: "辅导员",width: "150px"},
                    { field:"fjname", title: "助教",width: "150px"},
                    { field:"students_num", title: "学生数量",width: "150px"},
                    { command: [{name:"videoGrid",text:"<span class='k-icon k-i-group'></span>查看",click:queryStudentsList,buttonType:"ImageAndText"}], 
                    	attributes:{style:"text-align:center"},headerAttributes:{style:"text-align:center"},title: "操作", width: "100px" }
                    ]
            });
            
            $('#grid').css("height",document.body.clientHeight-40);
            //$("#isMember").kendoComboBox();
            $("#date_from").kendoDatePicker({format: "yyyy-MM-dd"});
            $("#date_to").kendoDatePicker({format: "yyyy-MM-dd"});
		});
		
		
		
		var queryCustomerList = function(e){//查询
			//$("#grid").data("kendoGrid").dataSource.read({date_from:$('#date_from').val(),date_to:$('#date_to').val()});
			$("#grid").data("kendoGrid").dataSource.fetch();
			$("#grid").data("kendoGrid").dataSource.page(1);
		}
		
		var selectTemp = function(dataItem){
			return "<label>是否会员:</label><select id='isMember' name='isMember'>"+
                		"<option value ='' selected='selected'></option>"+
                		"<option value ='1'>是</option>"+
                		"<option value ='0'>否</option>"+
		            "</select>";
		}
		
		//查看 课程学生
		var queryStudentsList = function(e){
			var grid = $("#grid").data("kendoGrid");
			e.preventDefault();
            var data = grid.dataItem($(e.currentTarget).closest("tr"));
            $('#studentslist').attr('href','${path}/assist/coursestudents?course_detail_id='+data.course_detail_id);
            setFormData(data);
			$.fancybox($("#studentslist"));
		}
		
		var setFormData = function(data){
			$('#baby_name').val(data.baby_name);
		}
		
    </script>
</head>
<body>
	<div id="toolbar" style="margin:2px"></div>
    <div id="grid" style="margin:2px;font-size:10px"></div>
    
    <a href="${path}/assist/coursestudents" class="fancybox fancybox.iframe" id="studentslist" title="课程学生" style="display:none"></a>
</body>
</html>
